package cn.fy.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import cn.fy.model.AppConfig;

@RestController
@RequestMapping("/config")
@RefreshScope
public class ConfigController {
	@Value("${useLocalCache:false}")
    private boolean useLocalCache;

	/**
	 * http://localhost:8080/config/get
	 * @return
	 */
    @RequestMapping("/get")
    public boolean get() {
        return useLocalCache;
    }
    
    //@Value("${languages.list1}")
    @Value("#{'${languages.list1}'.split(',')}")
    private List<String> list;
    
    /**
	 * http://localhost:8080/config/getLanguages
	 * @return
	 */
    @RequestMapping("/getLanguages")
    public List<String> getLanguages() {
        return list;
    }
    
    @Autowired
    private AppConfig appConfig;
    
    /**
	 * http://localhost:8080/config/getList1
	 * @return
	 */
    @RequestMapping("/getList1")
    public List<String> getList1() {
        return appConfig.getList1();
    }
    
    /**
	 * http://localhost:8080/config/getList2
	 * @return
	 */
    @RequestMapping("/getList2")
    public String[] getList2() {
        return appConfig.getList2();
    }
    
    /**
	 * http://localhost:8080/config/getList3
	 * @return
	 */
    @RequestMapping("/getList3")
    public List<String> getList3() {
        return appConfig.getList3();
    }
}
